﻿using System;
using Castle.Services.Transaction;
using Evolus.Mercury.Model;
using Hippo.Core.Data;

namespace Evolus.Mercury
{
    public class PortfolioService : IPorfolioService
    {
        IRepository repository;

        public PortfolioService(IRepository repository)
        {
            this.repository = repository;
        }

        [Transaction(TransactionMode.Requires)]
        public void CreatePortfolio(Portfolio porfolio)
        {

        }

        [Transaction(TransactionMode.Requires)]
        public void DeletePortfolio(int portfolioId)
        {
            throw new NotImplementedException();
        }

        [Transaction(TransactionMode.Requires)]
        public void AddTransaction(Transaction transaction)
        {
            repository.Create<Transaction>(transaction);
        }

        [Transaction(TransactionMode.Requires)]
        public void DeleteTransaction(int transactionId)
        {
            Transaction transaction = repository.GetById<Transaction>(transactionId);
            if (transaction != null)
            {
                repository.Delete(transaction);
            }
            else
            {
                // TODO: throw exception
            }
        }

        
    }
}
